home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-06 | 11.3 KB | 373 lines | [TEXT/KAHL] |
- $$Message User Types, u:Types$Prototype.name$.h
- $$File u:Types$Prototype.name$.h
- /* Types$Prototype.name$ types */
- /* $CopyRight$ */
-
- /*
- File name: Types$Prototype.name$.h
- Function: Type definitions for user changes.
- History: $Date$ Original by $Author$
-
- */
-
- /* ======================================================= */
- /* ======================================================= */
-
- class CApplication: public CmmApplication{ /* The Application itself */
- public:
- virtual void InitExtras(void); /* override */
- virtual void ExitExtras(void); /* override */
- $$if Option.EXTRAHOOKS
- virtual void TopOfLoop(void); /* HOOK at top of main event loop */
- virtual void FilterEvent(Boolean *DoIt,EventRecord *myEvent); /* HOOK, Filter events from the main loop */
- virtual void Handle_Extra_User_Event(UserEventPRec theUserEvent); /* Hook, to handle user events */
- virtual void OpenSplashWindow(void); /* Open spash or personalization window */
- virtual void CloseSplashWindow(void); /* Close spash or personalization window */
- $$endif Option.EXTRAHOOKS
- };
-
-
- class CMenus: public CmmMenus{ /* The Menu handlers */
- public:
- virtual void AddExtraMenus(void); /* override */
- $$if Option.EXTRAHOOKS
- virtual void EnableTheMenus(void); /* Enable or disable before they are dropped */
-
- $$Loop Menus
- virtual Boolean DoMenu$Menu.name$(short theItem); /* Handle this menu list, $Menu.FullName$ */
- $$EndLoop Menus
- $$Loop HierMenus
- virtual Boolean DoMenu$Menu.name$(short theItem); /* Handle this menu list, $Menu.FullName$ */
- $$EndLoop HierMenus
- $$endif Option.EXTRAHOOKS
- };
-
- class CPreferences: public CmmPreferences{ /* The Preferences routines */
- public:
- virtual void Init(void); /* override */
- virtual void USetPreferences(Handle thePrefsH); /* override */
- virtual void UGetPreferences(Handle thePrefsH); /* override */
- };
-
- class CFiles: public CmmFiles{ /* The Files routines */
- public:
- virtual void Close_The_Input_File(void);
- virtual void Open_The_File(void);
- virtual void Close_The_Output_File(void);
- virtual void Save_The_File(void);
- virtual void Select_Volume(void);
- };
-
- class CPrinting: public CmmPrinting{ /* The Printing routines */
- public:
- virtual void Print_The_Data(void); /* Override */
- };
-
- $$Loop Alerts
- /* Class for the Alert titled "$Worksheet.FullName$" */
- class CA$Worksheet.name$: public CmmA$Worksheet.name${ /* The window */
- public:
- virtual void Init(void); /* Override, Initialize the window variables */
- $$if Option.EXTRAHOOKS
- virtual void DoFirstTime(void); /* HOOK, Handle setup necessary for first time in */
- virtual void DoItemHit(short itemHit); /* HOOK, Handle setup necessary for first time in */
- $$endif Option.EXTRAHOOKS
- };
-
- $$EndLoop
- $$Loop ModalDialogs
- /* Class for the Modal Dialog titled "$Worksheet.FullName$" */
- class CD$Worksheet.name$: public CmmD$Worksheet.name${ /* The window */
- public:
- virtual void Init(void); /* Override, Initialize the window variables */
- $$if Option.EXTRAHOOKS
- virtual void Refresh(void); /* Update the Dialog */
- virtual void ExtraSetup(void);
- virtual void DoItemHit(short *itemHit,Boolean *ExitDialog); /* Let user handle the item hit */
- virtual void Exit(void); /* Exit the dialog */
- $$endif Option.EXTRAHOOKS
- };
-
- $$EndLoop
- $$Loop ModelessDialogs
- /* Class for the Modeless Dialog titled "$Worksheet.FullName$" */
- class CMD$Worksheet.name$: public CmmMD$Worksheet.name${ /* The window */
- public:
- virtual void Init(void); /* Override, Initialize the window variables */
- $$if Option.EXTRAHOOKS
- virtual void UpdateExtras(void); /* HOOK, allow user update code in */
- virtual void OpenExtras(void); /* HOOK, allow user open code in */
- virtual void Close(WindowPtr theWindow);
- virtual void HandleEvent(EventRecord *theEvent,WindowPtr theWindow,short itemHit);
- $$endif Option.EXTRAHOOKS
- };
-
- $$EndLoop
- $$Loop Windows
- /* Class for the window titled "$Worksheet.FullName$" */
- class CW$Worksheet.name$: public CmmW$Worksheet.name${ /* The window */
- public:
- virtual void Init(void); /* Override, Initialize the window variables */
- $$if Option.EXTRAHOOKS
- virtual void OpenExtras(Ptr theWS);
- virtual void CloseExtras(Ptr theWS);
- virtual void UpdateExtras(Ptr theWS);
- virtual void ActivateExtras(Boolean Do_An_Activate,Ptr theWS);
- virtual void HandleExtraButtons(Ptr theWS,ControlHandle theControl,short *UnHiliteValue);
- $$if Worksheet.CheckboxesOrRadios
- virtual void HandleExtraCheckboxes(Ptr theWS,ControlHandle theControl);
- $$endif
- $$if Worksheet.Scrollbars
- virtual void HandleScrollBar(short code,ControlHandle theControl,Point myPt);
- $$endif
- virtual void HandleEvent(EventRecord *myEvent);
- $$endif Option.EXTRAHOOKS
- };
-
- $$EndLoop
-
-
- /* ======================================================= */
- /* ======================================================= */
- $$CloseFile
- $$Message User Common, u:common$Prototype.name$.h
- $$File u:common$Prototype.name$.h
- /* common$Prototype.name$ Common */
- /* $CopyRight$ */
-
- /*
- File name: common$Prototype.name$.h
- Function: Common variables for program specific code.
- History: $Date$ Original by $Author$
-
- */
-
- /* ======================================================= */
- /* ======================================================= */
-
- #define PrefsCreator 'xxxx' /* Creator, this has to be the same as your App */
- #define PrefsType 'Pref' /* Type, this has to match the type in your BNDL */
- #define PrefsFileName "\p$Prototype.name$ Prefs" /* This is the name of your prefs file */
-
- #define PrefsFormatRevision 1 /* Change each time the format changes */
-
- /* NOTE : FormatRevision MUST be first in the record, and always a short */
- typedef struct PrefsRec{ /* Preferences Record definition */
- /* ALWAYS KEEP FormatRevision AS THE FIRST ELEMENT IN THIS RECORD */
- short FormatRevision; /* FIRST ALWAYS, Change each time the format changes */
- WindowLocRec theWindowLocRec; /* For saving window positions */
-
- /* Add other preference variable definitions after this line */
-
- }PrefsRec,*PrefsPRec,**PrefsHRec;
-
- /* ======================================================= */
- /* ======================================================= */
- $$CloseFile
- $$Message User Common, u:common$Prototype.name$.cp
- $$File u:common$Prototype.name$.cp
- /* common$Prototype.name$ Common */
- /* $CopyRight$ */
-
- /*
- File name: common$Prototype.name$
- Function: Common variables for program specific code.
- History: $Date$ Original by $Author$
-
- */
-
-
- #include "mmCommon$Prototype.name$.h" /* Common */
- #include "common$Prototype.name$.h" /* Common */
-
- /* ======================================================= */
- /* ======================================================= */
-
- /* ======================================================= */
-
- /* Routine: Init */
- /* Purpose: Set the default preferences */
-
- void CPreferences::Init(void)
- {
- inherited::Init();
- }
-
- /* ======================================================= */
-
- /* Routine: USetPreferences */
- /* Purpose: Set new preferences, to be written out to the file */
-
- void CPreferences::USetPreferences(Handle thePrefsH)
- {
- PrefsHRec thePrefs;
-
- inherited::USetPreferences(thePrefsH);
-
- thePrefs = (PrefsHRec)thePrefsH;
- /* Use the form: (*thePrefs)->xxxx = xxxx; */
- }
-
- /* ======================================================= */
-
- /* Routine: UGetPreferences */
- /* Purpose: Get the preferences from the Prefs record already read in */
-
- void CPreferences::UGetPreferences(Handle thePrefsH)
- {
- PrefsHRec thePrefs;
-
- inherited::UGetPreferences(thePrefsH);
-
- thePrefs = (PrefsHRec)thePrefsH;
- /* Use the form: xxxx = (*thePrefs)->xxxx; */
- }
-
- /* ======================================================= */
- /* ======================================================= */
-
- /* Routine: Close_The_Input_File */
- /* Purpose: Close the input file */
-
- void CFiles::Close_The_Input_File()
- {
- inherited::Close_The_Input_File();
- }
-
- /* ======================================================= */
-
- /* Routine: Close_The_Output_File */
- /* Purpose: Close the output file */
-
- void CFiles::Close_The_Output_File()
- {
- inherited::Close_The_Output_File();
- }
-
- /* ======================================================= */
-
- /* Routine: Open_The_File */
- /* Purpose: Open the input file */
-
- void CFiles::Open_The_File()
- {
- short NumberOfTypes;
- short theVolRefNum;
- OSErr ErrorCode;
-
-
- this->Files.typeList[0] = 'TEXT'; /* Open TEXT files */
- this->Files.typeList[1] = 'text'; /* Open other files */
- NumberOfTypes = 1; /* Only use first filetype in the list */
- if (Do_The_Open_File(NumberOfTypes,&theVolRefNum,nil,nil))/* Try to open the file */
- {
- ErrorCode = FSOpen(this->Files.inputFileName,this->Files.Reply.vRefNum,&this->Files.inputRefNum);/* Open the file */
-
- /* ADD in your code here to read the file */
-
- this->Close_The_Input_File(); /* Now close this file */
- }
- }
-
- /* ======================================================= */
-
- /* Routine: Select_Volume */
- /* Purpose: Select a volume */
-
- void CFiles::Select_Volume()
- {
- FSSpec theFile;
-
-
- if (Has.NewStdFile) /* Do this if we have new Standard File available */
- {
- if (this->Do_The_Select_Volume(&theFile))
- {
- }
- }
- else
- {
- }
- }
-
- /* ======================================================= */
-
- /* Routine: Save_The_File */
- /* Purpose: Save the file */
-
- void CFiles::Save_The_File()
- {
- short theVolRefNum;
- short theRefNum;
-
-
- if (this->Do_The_Save_File('xxxx', 'TEXT',(Str255 *)"\pSave as:",(Str255 *)"\pUntitled",/* Try to save the file */
- &theVolRefNum,&theRefNum,nil))
- {
-
- /* ADD in your code here to save the file */
-
- this->Close_The_Output_File(); /* Now close this file */
- } /* End of IF */
- }
-
- /* ======================================================= */
-
- /* Routine: Print_The_Data */
- /* Purpose: Print the data */
-
- void CPrinting::Print_The_Data()
- {
- GrafPtr ThePrintPort; /* Print port */
- GrafPtr SavedPort; /* saved window port */
- short Doing_Page; /* Current print page number */
- short NumberOfCopies; /* Number of copies of each page */
- short Count; /* Number of copies of each page */
- Boolean Cancelled; /* User cancelled flag */
- short NumberOfPages; /* Change this for the number of pages to do */
- Str255 ThePageString; /* For showing the page number */
-
-
- GetPort(&SavedPort); /* Get the current window port */
-
- NumberOfPages = 2; /* CHANGE for your pages limit */
- this->OpenThePrinter(&Cancelled); /* Ask about the next page */
-
- if ((Printing.pPrPort != NIL) && (Printing.hPrint != NIL) && (!Cancelled))
- {
- ThePrintPort = (GrafPtr)Printing.pPrPort; /* Get the current window port */
- SetPort(ThePrintPort); /* Point to the printer port */
- TextFont(systemFont);
- TextSize(12);
- Doing_Page = 0;
-
- do /* Do all the pages in our document */
- {
- InitCursor();
- Doing_Page = Doing_Page + 1; /* Bump the page count */
-
- PrOpenPage(Printing.pPrPort, nil); /* Open a new page */
- SetPort(ThePrintPort);
-
- /* ADD YOUR PRINTING CODE HERE, DRAW INTO THIS PORT */
- MoveTo(10, 20);
- DrawString((StringPtr)"\pPrinting from Marksman™ code, page ");
- NumToString(Doing_Page,ThePageString);
- DrawString(ThePageString);
- /* END OF ADD YOUR PRINTING CODE HERE */
-
- PrClosePage(Printing.pPrPort); /* Print this page */
- SetPort(SavedPort);
- }
- while (Doing_Page < NumberOfPages);
- }
-
- this->CloseThePrinter(); /* Close the printer */
- SetPort(SavedPort);
- InitCursor();
- }
-
- /* ======================================================= */
- /* ======================================================= */
- $$CloseFile
-